package app.server.project.core.tcp.model;

import cn.hutool.json.JSONUtil;
import lombok.Data;
import lombok.experimental.Accessors;

@Data
@Accessors(chain = true)
public class TcpRespModel {
    /**
     * 命令控制字
     */
    private int cmd;
    /**
     * 业务逻辑数据 字典类型
     */
    private Object data;

    public byte[] toByte(){
        return JSONUtil.toJsonStr(this).getBytes();
    }

    public static TcpRespModel of(int cmd,Object data){
       return new TcpRespModel()
               .setData(data)
               .setCmd(cmd);
    }
}
